﻿using System;

namespace HYBY.Task.Repository.Dapper
{
    /// <summary>
    /// 根据SQL模板生成的查询SQL参数对象
    /// </summary>
    public partial class SqlStatement : ICloneable
    {
        /// <summary>
        /// SQL ID
        /// </summary>
        public string StatementId { get; set; }

        /// <summary>
        /// SQL语句
        /// </summary>
        public string StatementText { get; set; }

        /// <summary>
        /// 是否缓存该SQL
        /// </summary>
        public bool IsCached { get; set; }

        /// <summary>
        /// 过期时间
        /// </summary>
        public int Expired { get; set; }

        /// <summary>
        /// 主键
        /// </summary>
        public string PrimaryKey { get; set; }

        /// <summary>
        /// 查询数据源名称
        /// </summary>
        public string SourceName { get; set; }

        /// <summary>
        /// 分组
        /// </summary>
        public string Group { get; set; }

        /// <summary>
        /// 查询条件
        /// </summary>
        public string Where { get; set; }

        /// <summary>
        /// 排序条件
        /// </summary>
        public string Order { get; set; }

        public object Clone()
        {

            return new SqlStatement
                       {
                           Expired = this.Expired,
                           IsCached = this.IsCached,
                           PrimaryKey = this.PrimaryKey,
                           StatementId = this.StatementId,
                           StatementText = this.StatementText,
                           SourceName = this.SourceName,
                           Where = this.Where,
                           Order = this.Order
                       };

        }
    }
    public class SqlReadOnlyStatement
    {
        public string StatementId { get; set; }
        public bool IsForceReadOnly { get; set; }
    }
}
